package com.funlog.designpattern.strategy.demo01;

public class Client {
    public static void main(String[] args) {
        //使用上下文
        System.out.println("使用上下文");
        Context context = new Context();
        context.setStrategy(new ConcreteStrategyA());
        context.executeStrategy();  // 执行策略A

        context.setStrategy(new ConcreteStrategyB());
        context.executeStrategy();  // 执行策略B

        //不使用上下文
        System.out.println("不使用上下文");
        Strategy strategy=new ConcreteStrategyA();
        strategy.execute();

        strategy=new ConcreteStrategyB();
        strategy.execute();

    }
}
